#    Tichy
#
#    copyright 2008 Guillaume Chereau (charlie137@gmail.com)
#
#    This file is part of Tichy.
#
#    Tichy is free software: you can redistribute it and/or modify it
#    under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Tichy is distributed in the hope that it will be useful, but
#    WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#    General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Tichy.  If not, see <http://www.gnu.org/licenses/>.

import pygame
import pygame.font

import logging
logger = logging.getLogger('font')


class Font(pygame.font.Font):

    def __init__(self, name=None, size=32):
        # name = name or 'arplumingtwmbe'
        # file = pygame.font.match_font(name)
        # XXX: hack
        paths = ['/usr/share/fonts/truetype/arphic/bkai00mp.ttf',
                 '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf']
        for path in paths:
            try:
                super(Font, self).__init__(path, size)
                break
            except IOError:
                pass
        else:
            logger.warning("can't find any fonts file, using default")
            super(Font, self).__init__(None, size)
